<?php
    require_once 'classes/JobPost.php';
    require_once 'classes/Login.php';
    $Login = new Login();
    $JobPost = new JobPost();
    include 'includes/header.inc.php';
    $jobID = $_GET['jobID'];
    $empID = $_SESSION['employerID'];
    $jobListing = $JobPost->getPost($jobID, $empID);
    if($jobListing != 'ERROR')
    {
        $expiredDate = strtotime("-90 days");
        $jobDate = strtotime($jobListing[8]);
        if($jobDate < $expiredDate)
        {
            $expiredFlag = true;
        }
        else
        {
            $expiredFlag = false;
        }
        $jobLocations = $JobPost->getLocations($jobID);
        $companyName = $Login->getCompanyName($jobListing[0]);
?>
        <div id="postBox">
        <section id="advancedSearch">
            <h2>Advanced Search</h2>
            <form id="advSearch" action="#">
                <div id="leftAdvS" class="advS">
                    <label for="what">what</label>
                    <input id="what" type="text" />
                    <small>Joe title, keywords, or company name</small>
                </div>
                <div id="centerAdvS" class="advS">
                    <label for="where">where</label>
                    <input id="where" type="text" />
                    <small>City, State, or Zip (Optional)</small>
                </div>
                <div id="rightAdvS" class="advS">
                    <input type="submit" name="advSearch" id="advSearch" class="button" value="Find Jobs" />
                </div>
            </form>
        </section>
        <hr />
        <section id="jobPost">
            <?php if($expiredFlag == true){ echo '<h1 class="expired">EXPIRED</h1>'; } ?>
            <h2><strong><?php echo $jobListing[1]; ?></strong></h2>
            <?php
                    if($jobListing[6] != 0){ echo '<p><strong>Company Name:</strong> '.$companyName.'</p>'; }
                    if($jobListing[7] != 0){ echo '<p class="jobLocation"><strong>Salary: </strong>'.$jobListing[4].'</p>'; }
                    foreach($jobLocations as $i=>$jobLocation)
                    {
                        $stateName = $JobPost->getStateName($jobLocation[1]);
                        echo '<p class="jobLocation">'.$jobLocation[0].', '.$stateName.'</p>';
                    }
                    $postDate = strtotime($jobListing[8]);
                    echo '<p>Date Posted: '.date("m/d/y", $postDate).'</p>';
             ?>
            <p>&nbsp;</p>
            <p><?php echo nl2br($jobListing[3]); ?></p>
            <p>&nbsp;</p>
                    <div id="loading"><img src="/sandbox1/media/images/loader.gif" alt="Loading..." /></div>
                    <div id="feedback"></div>
            <div id="form" class="applyForm">
                <fieldset>
                    <legend>Apply Here!</legend>
                    <form>
                        <p>
                            <label for="fName">First Name: </label>
                            <input type="text" name="fName" id="fName" class="input" value=""/>
                        </p>
                        <p>
                            <label for="lName">Last Name: </label>
                            <input type="text" name="lName" id="lName" class="input" value=""/>
                        </p>
                        <p>
                            <label for="email">Email Address: </label>
                            <input type="text" name="email" id="email" class="input" value=""/>
                        </p>
                        <p>
                            <label for="confEmail">Confirm Email Address: </label>
                            <input type="text" name="confEmail" id="confEmail" class="input" value=""/>
                        </p>
                        <p>
                            <label for="resumeText">Copy/Paste Resume: </label>
                            <textarea name="resumeText" id="resumeText"></textarea>
                        </p>
                    </form>
                </fieldset>
            </div>
        </section>
    </div>
<?php
    }
    else
    {
        echo '<div id="noResults">The job post you selected, is either deleted or expired.</div>';
    }
include 'includes/footer.inc.php'; ?>